<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AlterUserKeyworldEncry extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('email',255)->after('name')->default('')->comment('加密后邮箱地址')->change();
            $table->string('phone',255)->after('email')->default('')->comment('加密后手机号码')->change();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (!Schema::hasColumn('users', 'email')){
            Schema::table('users', function (Blueprint $table) {
                $table->string('email',50)->after('name')->default('')->comment('邮箱');
            });
        }
        if (!Schema::hasColumn('users', 'phone')){
            Schema::table('users', function (Blueprint $table) {
                $table->string('phone',11)->after('email')->default('')->comment('绑定手机号');
            });
        }
    }
}
